package com.goodomen.garbage.score.util;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

public class DateConvertUtil {

    private static final ZoneId ZONE = ZoneId.systemDefault();

    private DateConvertUtil() { }

    /**
     * 格式化日期
     *
     * @param date
     * @return
     */
    public static LocalDateTime convert2LocalDateTime(Date date) {
        if (date == null) {
            return null;
        }
        return LocalDateTime.ofInstant(date.toInstant(), ZONE);
    }

    /**
     * 格式化日期
     *
     * @param date
     * @return
     */
    public static LocalDate convert2LocalDate(Date date) {
        if (date == null) {
            return null;
        }
        return LocalDateTime.ofInstant(date.toInstant(), ZONE).toLocalDate();
    }
}
